VERSU=1_2_8
VERSD=1.2.8
-RELEASE=-beta11082005
+RELEASE=-beta11102005
VERSIONU=$(VERSU)$(RELEASE)
VERSIOND=$(VERSD)$(RELEASE)
void waypt_del (waypoint *);
void waypt_free (waypoint *);
void waypt_disp_all(waypt_cb);
+void waypt_init_bounds(bounds *bounds);
+int waypt_bounds_valid(bounds *bounds);
+void waypt_add_to_bounds(bounds *bounds, const waypoint *waypointp);
void waypt_compute_bounds(bounds *);
void waypt_flush(queue *);
void waypt_flush_all(void);
static char *urlbase = NULL;
static route_head *trk_head;
static route_head *rte_head;
+/* used for bounds calculation on output */
+static bounds all_bounds;
static format_specific_data **fs_ptr;
gpx_rm_from_global(gpx_global_entry *ge)
{
queue *elem, *tmp;
- gpx_global_entry * gep;
QUEUE_FOR_EACH(&ge->queue, elem, tmp) {
gpx_global_entry *g = (gpx_global_entry *) dequeue(elem);
route_disp_all(gpx_route_hdr, gpx_route_tlr, gpx_route_disp);
}
+static void
+gpx_waypt_bound_calc(const waypoint *waypointp)
+{
+ waypt_add_to_bounds(&all_bounds, waypointp);
+}
+
+static void
+gpx_write_bounds(void)
+{
+ waypt_init_bounds(&all_bounds);
+
+ waypt_disp_all(gpx_waypt_bound_calc);
+ route_disp_all(NULL, NULL, gpx_waypt_bound_calc);
+ track_disp_all(NULL, NULL, gpx_waypt_bound_calc);
+
+ if (waypt_bounds_valid(&all_bounds)) {
+ fprintf(ofd, "<bounds minlat=\"%0.9f\" minlon =\"%0.9f\" "
+ "maxlat=\"%0.9f\" maxlon=\"%0.9f\" />\n",
+ all_bounds.min_lat, all_bounds.min_lon,
+ all_bounds.max_lat, all_bounds.max_lon);
+ }
+}
+
static void
gpx_write(void)
{
time_t now = 0;
int short_length;
- bounds bounds;
gpx_wversion_num = strtod(gpx_wversion, NULL) * 10;
xml_write_time( ofd, now, "time" );
gpx_write_gdata(&gpx_global->keywords, "keywords");
- waypt_compute_bounds(&bounds);
- if (bounds.max_lat > -360) {
- fprintf(ofd, "<bounds minlat=\"%0.9f\" minlon =\"%0.9f\" "
- "maxlat=\"%0.9f\" maxlon=\"%0.9f\" />\n",
- bounds.min_lat, bounds.min_lon,
- bounds.max_lat, bounds.max_lon);
- }
+ gpx_write_bounds();
if (gpx_wversion_num > 10) {
fprintf(ofd, "</metadata>\n");
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
-<bounds minlat="34.019184000" minlon ="-122.441589000" maxlat="37.229349000" maxlon="-120.438209000" />
+<bounds minlat="34.019184000" minlon ="-122.605838000" maxlat="37.819339000" maxlon="-120.438209000" />
<wpt lat="37.229349000" lon="-122.441589000">
<time>2004-11-05T21:13:00Z</time>
<name>PESCDR01</name>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
-<bounds minlat="50.492618987" minlon ="12.105448823" maxlat="51.314520836" maxlon="12.435919438" />
+<bounds minlat="50.476993863" minlon ="12.090926170" maxlat="51.315169176" maxlon="12.510294914" />
<wpt lat="50.877340632" lon="12.433888670">
<name>3</name>
<cmt>B93</cmt>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="-30.765600000" minlon ="150.602533333" maxlat="-30.675433333" maxlon="150.725983333" />
<rte>
<name>0001</name>
<desc>IGCDATE000000: </desc>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="51.118766667" minlon ="-2.920450000" maxlat="54.118683333" maxlon="-0.293533333" />
<rte>
<name>0001</name>
<desc>IGCDATE160701: 500KTri</desc>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="45.754467000" minlon ="11.449617000" maxlat="45.789383000" maxlon="11.553583000" />
<rte>
<name>test</name>
<rtept lat="45.789383000" lon="11.553583000">
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
-<bounds minlat="47.545980000" minlon ="2.665770000" maxlat="47.565210000" maxlon="2.713690000" />
+<bounds minlat="47.543230000" minlon ="2.664750000" maxlat="47.565520000" maxlon="2.722340000" />
<wpt lat="47.565210000" lon="2.713690000">
<ele>1272.900000</ele>
<time>2005-06-18T08:53:36Z</time>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
-<bounds minlat="49.469250000" minlon ="11.046166667" maxlat="49.935527778" maxlon="11.476083333" />
+<bounds minlat="49.445861111" minlon ="11.044861111" maxlat="49.935944444" maxlon="11.481583333" />
<wpt lat="49.718250000" lon="11.066416667">
<name>Jägersburg in Forchheim geradeaus weiter auf Eisenbahnstrasse</name>
<cmt>Jägersburg in Forchheim geradeaus weiter auf Eisenbahnstrasse</cmt>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="50.497369766" minlon ="12.135772705" maxlat="50.628690720" maxlon="12.998456955" />
<rte>
<rtept lat="50.497369766" lon="12.135772705">
<name>Plauen</name>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="49.021900000" minlon ="11.587670000" maxlat="50.494250000" maxlon="12.675630000" />
<rte>
<rtept lat="50.494250000" lon="12.107270000">
<name>RPT001</name>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
-<bounds minlat="50.271540000" minlon ="11.642810000" maxlat="50.756270000" maxlon="12.671250000" />
+<bounds minlat="50.268830000" minlon ="11.640990000" maxlat="50.756540000" maxlon="12.696920000" />
<wpt lat="50.362350000" lon="11.903730000">
<name>in Zedtwitz halb rechts halten auf B2 Hofer Strasse</name>
<cmt>B2 Hofer Strasse</cmt>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="51.312750000" minlon ="12.409350000" maxlat="51.314650000" maxlon="12.414983333" />
<trk>
<name>ACTIVE LOG 006</name>
<trkseg>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="45.660805000" minlon ="6.365717000" maxlat="45.667271000" maxlon="6.372394000" />
<trk>
<desc>20050719 Mar Tamié ind 2 VTT Sem Europ</desc>
<trkseg>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="50.319399833" minlon ="11.700503833" maxlat="50.496254000" maxlon="12.138562167" />
<trk>
<name>20050116_Fahrradtour Gerd</name>
<trkseg>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="45.177499900" minlon ="4.634587200" maxlat="45.187113000" maxlon="4.660729700" />
<trk>
<trkseg>
<trkpt lat="45.187113000" lon="4.660729700">
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="30.045517000" minlon ="-91.610567000" maxlat="30.062783000" maxlon="-91.589750000" />
<trk>
<name>LOG-20020525</name>
<trkseg>
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="45.458204984" minlon ="-75.770526640" maxlat="45.497519984" maxlon="-75.684934974" />
<trk>
<trkseg>
<trkpt lat="45.460366651" lon="-75.767939974">
}
}
+void
+waypt_init_bounds(bounds *bounds)
+{
+ /* Set data out of bounds so that even one waypoint will reset */
+ bounds->max_lat = -9999;
+ bounds->max_lon = -9999;
+ bounds->min_lat = 9999;
+ bounds->min_lon = 9999;
+}
+
+int
+waypt_bounds_valid(bounds *bounds)
+{
+ /* Returns true if bb has any 'real' data in it */
+ return bounds->max_lat > -9999;
+}
+
+/*
+ * Recompund bounding box based on new position point.
+ */
+void
+waypt_add_to_bounds(bounds *bounds, const waypoint *waypointp)
+{
+ if (waypointp->latitude > bounds->max_lat)
+ bounds->max_lat = waypointp->latitude;
+ if (waypointp->longitude > bounds->max_lon)
+ bounds->max_lon = waypointp->longitude;
+ if (waypointp->latitude < bounds->min_lat)
+ bounds->min_lat = waypointp->latitude;
+ if (waypointp->longitude < bounds->min_lon)
+ bounds->min_lon = waypointp->longitude;
+}
+
+
/*
* Makes another pass over the data to compute bounding
* box data and populates bounding box information.
queue *elem, *tmp;
waypoint *waypointp;
- /* Set data out of bounds so that even one waypoint will reset */
- bounds->max_lat = -9999;
- bounds->max_lon = -9999;
- bounds->min_lat = 9999;
- bounds->min_lon = 9999;
+ waypt_init_bounds(bounds);
QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
waypointp = (waypoint *) elem;
- if (waypointp->latitude > bounds->max_lat)
- bounds->max_lat = waypointp->latitude;
- if (waypointp->longitude > bounds->max_lon)
- bounds->max_lon = waypointp->longitude;
- if (waypointp->latitude < bounds->min_lat)
- bounds->min_lat = waypointp->latitude;
- if (waypointp->longitude < bounds->min_lon)
- bounds->min_lon = waypointp->longitude;
+ waypt_add_to_bounds(bounds, waypointp);
}
}